package easy;

import java.util.*;

public class Solution_LCP_44 {
    public int numColor(TreeNode root) {
        Set<Integer> set = new HashSet<>();
        Stack<TreeNode> stack = new Stack<>();
        stack.add(root);
        while (!stack.empty()) {
            TreeNode pop = stack.pop();
            set.add(pop.val);
            if (pop.left != null) {
                stack.push(pop.left);
            }
            if (pop.right != null) {
                stack.push(pop.right);
            }
        }
        return set.size();
    }

    public static void main(String[] args) {
        Solution_LCP_44 model = new Solution_LCP_44();

    }

    static class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }
}
